package com.pw.gmall.realtime.app;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.state.hashmap.HashMapStateBackend;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.environment.CheckpointConfig;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Author: linux_future
 * @since: 2022/3/26
 **/
public abstract class BaseSqlTestApp {
    public void init(int port, int p, String ck) {
        System.setProperty("HADOOP_USER_NAME", "atguigu");
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", port);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(p);

        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
        handle(tEnv);

        try {
            env.execute(ck);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    protected abstract void handle(StreamTableEnvironment tEnv);


}
